-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(starknet_l1_provider): add fake l1 provider client #2856
base: gilad/add-scraper-3
Are you sure you want to change the base?
Conversation
5c5c34b
to
66ceab0
Compare
Artifacts upload workflows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @giladchase and @matan-starkware)
crates/starknet_l1_provider/src/test_utils.rs
line 138 at r1 (raw file):
#[derive(Default)] pub struct FakeL1ProviderClient {
Are we using "fake" throughout the codebase? Maybe "mock" is better?
Consistency is more important though.
Code quote:
Fake
crates/starknet_l1_provider/src/test_utils.rs
line 139 at r1 (raw file):
#[derive(Default)] pub struct FakeL1ProviderClient { pub events_received: Mutex<Vec<Event>>,
Why? Is it accessed concurrently?
Code quote:
Mutex
crates/starknet_l1_provider/src/test_utils.rs
line 145 at r1 (raw file):
#[track_caller] pub fn assert_add_events_received_with(&self, expected: &[Event]) { assert_eq!(self.events_received.lock().unwrap().drain(..).collect_vec(), expected);
Noice.
Code quote:
.drain(..)
crates/starknet_l1_provider/src/test_utils.rs
line 161 at r1 (raw file):
Ok(()) } async fn validate(
Suggestion:
}
async fn add_events(&self, events: Vec<Event>) -> L1ProviderClientResult<()> {
self.events_received.lock().unwrap().extend(events);
Ok(())
}
async fn validate(
5ae8a1d
to
1a8875a
Compare
66ceab0
to
ef44633
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @giladchase and @matan-starkware)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @elintul and @giladchase)
crates/starknet_l1_provider/src/test_utils.rs
line 138 at r1 (raw file):
Previously, elintul (Elin) wrote…
Are we using "fake" throughout the codebase? Maybe "mock" is better?
Consistency is more important though.
My understanding is that mock means something like automock, where the test sets explicit expectations for each call and there is no implementation.
Fake refers to a real, albeit simplified, implementation.
crates/starknet_l1_provider/src/test_utils.rs
line 139 at r1 (raw file):
Previously, elintul (Elin) wrote…
Why? Is it accessed concurrently?
Is there a plan in the future for the Scraper and Batcher to hold Arc<FakeL1ProviderClient>
leading to shared usage with no server? If it's something like this, might be nice to have a small docstring on the struct stating that.
crates/starknet_l1_provider/src/test_utils.rs
line 145 at r1 (raw file):
Previously, elintul (Elin) wrote…
Noice.
Why not take? https://doc.rust-lang.org/std/mem/fn.take.html
crates/starknet_l1_provider/src/test_utils.rs
line 143 at r2 (raw file):
impl FakeL1ProviderClient { #[track_caller]
What's this?
Code quote:
#[track_caller]
No description provided.